﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tbTIENDOGIANGDAY
/// </summary>
public class cls_tbTIENDOGIANGDAY
{
	public cls_tbTIENDOGIANGDAY()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    #region Select
    public DataTable Select()
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            dt = connect.GetSelectCommand("tbTIENDOGIANGDAY_SELECT", null);
        }
        catch
        {
            dt = null;
        }
        return dt;
    }
    public DataTable GetByMaCN(string F_MACN)
    {
        DataTable dt = new DataTable();
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);

        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            dt = connect.GetSelectCommand("tbTIENDOGIANGDAY_GetByMaCN", para);
        }
        catch
        {
            dt = null;
        }
        return dt;
    }
    public DataTable GetByMaCN_MaCHN(string F_MACN, string F_MACHN)
    {
        DataTable dt = new DataTable();
        SqlParameter[] para = new SqlParameter[2];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        para[1] = new SqlParameter("@F_MACHN", F_MACHN);
        DatabaseConnect connect = new DatabaseConnect();
        try
        {
            dt = connect.GetSelectCommand("tbTIENDOGIANGDAY_GetByMaCN_MaCHN", para);
        }
        catch
        {
            dt = null;
        }
        return dt;
    } 
    #endregion

    #region Update tiến độ
    public string Update(string F_MALOP, int F_SOTIETCHUAN, DateTime F_NGAYCHOTSODAUBAI, int F_SOTIET, string F_BAIHOCTHUCTE, string F_BAIHOCCHUAN, int F_SOTIETCONLAI, string F_NGAYTHICHUAN, DateTime F_NGAYKETTHUCCHUAN, string F_NGAYTHIDUKIEN, DateTime F_NGAYKETTHUCDUKIEN, string F_GHICHU)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[12];
        para[0] = new SqlParameter("@F_MALOP", F_MALOP);
        para[1] = new SqlParameter("@F_SOTIETCHUAN", F_SOTIETCHUAN);
        para[2] = new SqlParameter("@F_NGAYCHOTSODAUBAI", F_NGAYCHOTSODAUBAI);
        para[3] = new SqlParameter("@F_SOTIET", F_SOTIET);
        para[4] = new SqlParameter("@F_BAIHOCTHUCTE", F_BAIHOCTHUCTE);
        para[5] = new SqlParameter("@F_BAIHOCCHUAN", F_BAIHOCCHUAN);
        para[6] = new SqlParameter("@F_SOTIETCONLAI", F_SOTIETCONLAI);
        para[7] = new SqlParameter("@F_NGAYTHICHUAN", F_NGAYTHICHUAN);
        para[8] = new SqlParameter("@F_NGAYKETTHUCCHUAN", F_NGAYKETTHUCCHUAN);
        para[9] = new SqlParameter("@F_NGAYTHIDUKIEN", F_NGAYTHIDUKIEN);
        para[10] = new SqlParameter("@F_NGAYKETTHUCDUKIEN", F_NGAYKETTHUCDUKIEN);
        para[11] = new SqlParameter("@F_GHICHU", F_GHICHU);

        try
        {
            connect.ExecuteQuery("tbTIENDOGIANGDAY_Update", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    #endregion
}